<template>
  <!-- 面试技巧列表 -->
  <div class="technicList">
    <div class="title">
      <i class="iconfont iconbtn_nav_back icon" @click="back"></i>
      <div class="text">面试技巧</div>
    </div>
    <div class="search" @click="$router.push(`/search/${technic}`)">
      <i class="iconfont iconicon_search icon"></i>
      <span>请输入关键字</span>
    </div>
    <div class="content">
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
      >
        <technicItem
          v-for="(item, index) in viewList"
          :key="index"
          :item="item"
        ></technicItem>
      </van-list>
    </div>
  </div>
</template>

<script>
import { articlesTechnic } from '@/api/api.js'
import technicItem from './technicItem.vue'
export default {
  components: {
    technicItem
  },
  data () {
    return {
      loading: false,
      finished: false,
      viewList: [],
      size: 0,
      technic: 'technic'
    }
  },
  methods: {
    // 返回上页
    back () {
      this.$router.go(-1)
    },
    async onLoad () {
      // 获取数据列表
      const res = await articlesTechnic({ start: this.size })
      // console.log(res.data.list)
      this.viewList = [...this.viewList, ...res.data.list]
      this.loading = false
      if (!res.data.list.length) {
        this.finished = true
      }
      this.size += 5
    }
  }
}
</script>

<style lang="less" scoped>
.technicList {
  font-size: 16px;
  .title {
    display: flex;
    align-items: center;
    .icon {
      font-size: 40px;
    }
    .text {
      font-size: 20px;
      width: 80%;
      text-align: center;
    }
  }
  .search {
    background-color: #f7f4f5;
    height: 32px;
    margin: 0 10px;
    border-radius: 16px;
    text-align: center;
    line-height: 32px;
    color: #b3b3b3;
    .icon {
      font-size: 18px;
      vertical-align: middle;
    }
  }
  .item {
    display: flex;
    padding-bottom: 20px;
    .left {
      flex: 6;
      margin-right: 20px;
      .bottom {
        margin-top: 30px;
        font-size: 12px;
        color: #b4b4bd;
        .mid {
          margin: 0 20px 0 50px;
        }
      }
    }
    .right {
      flex: 4;
      img {
        width: 100%;
      }
    }
  }
  .content {
    padding: 10px;
  }
}
</style>
